We are migrating the bug tracker to github Issues. This is now the preferred way to report NASM bugs.

Self-registration is disabled due to spam issue (mail gorcunov@gmail.com or hpa@zytor.com to create an account)

Bug 3392948 - Warning message "OBJ format does not support alignment" never shown
Summary: Warning message "OBJ format does not support alignment" never shown
Status: CLOSED FIXED
Alias: None
Product: NASM
Classification: Unclassified
Component: Assembler (show other bugs)
Version: 3.00.xx
Hardware: All All
: Medium minor
Assignee: nobody
URL:
Depends on:
Blocks:
 
Reported: 2025-08-28 10:17 PDT by E. C. Masloch
Modified: 2025-09-05 22:12 PDT (History)
5 users (show)

Obtained from: Built from git using configure
Generated by: Human
Bug category: Other, Unexpected or confusing behavior
Observed for: Valid test code
Regression: No
Regression since:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description E. C. Masloch 2025-08-28 10:17:05 PDT
The warnings from the OMF OBJ format about unsupported alignment values is never displayed. It is generated here: https://github.com/netwide-assembler/nasm/blob/9ea92eab6e26b5527e2dc72424a886a1a4061a48/output/outobj.c#L1487

In the following test, nasm is my current production version of NASM. ~/proj/nasm/nasm is a patched variation on the current git head. The patch is as follows:

diff --git a/output/outobj.c b/output/outobj.c
index f8dd7b71..ff66fc7c 100644
--- a/output/outobj.c
+++ b/output/outobj.c
@@ -1484,6 +1484,7 @@ static int32_t obj_segment(char *name, int *bits)
                 case 4096:     /* PharLap extension */
                     break;
                 case 8:
+                    nasm_nonfatal("foo");
                     nasm_warn(WARN_OTHER, "OBJ format does not support alignment"
                               " of 8: rounding up to 16");
                     seg->align = 16;


Test run:

test$ cat test.asm

section QUUX class=QUUX
        db 26h

section FOO align=BAR class=FOO
        align BAR
        nop

section STACK class=STACK stack align=16
        resb 512
test$ ~/proj/nasm/nasm -f obj test.asm -DBAR=8 -o test8.obj -Wall
test.asm:5: error: foo
test.asm:5: warning: OBJ format does not support alignment of 8: rounding up to 16 [-w+other]
test$ nasm -v
NASM version 2.16.02rc2 compiled on Oct 12 2023
test$ nasm -f obj test.asm -DBAR=8 -o test8.obj -Wall
test$

Without the nasm_nonfatal patch, the current git head also doesn't show the warning at all.
Comment 1 E. C. Masloch 2025-08-28 10:18:19 PDT
Removing the align BAR directive does not change the result.
Comment 2 E. C. Masloch 2025-08-28 10:23:49 PDT
The code that adjusts the alignment does seem to run. The following test shows how NASM encodes the alignment, and the encoding matches what is expected (8 rounded to 16, and 32 + 64 + 128 rounded to 256, higher rounded to 4096). Test done using https://github.com/boeckmann/omfdump/blob/main/omfdump.c#L356 and warplink.exe renamed from https://pushbx.org/ecm/download/old/warplink/20240801.zip wl.exe and https://hg.pushbx.org/ecm/msdos4/file/181bc2652e51/warplink.sh

test$ for bar in 0 1 2 3 4 8 16 32 64 128 256 512 1024 2048 4096 8192; do echo -ne "$bar: " && nasm -DBAR=$bar test.asm -f obj && ~/proj/omfdump/omfdump test.obj | grep PUBLIC | tail -n1; ~/proj/msdos4.hg/hg/warplink.sh /mx test.obj,test.exe,test.map\; > /dev/null && cat test.map | perl -pe 's/\s+TEST.ASM\s+TEST.OBJ//' | grep PUBLIC | grep FOO; done
0: test.asm:5: error: invalid alignment value 0
test.asm:6: error: segment alignment `0' is not power of two
test.asm:6: error: division by zero
1:      BYTE (A1) PUBLIC (C2) USE16 size 0001
FOO                   0000:0001  0001h BYTE  PUBLIC  FOO
2:      WORD (A2) PUBLIC (C2) USE16 size 0001
FOO                   0000:0002  0001h WORD  PUBLIC  FOO
3: test.asm:5: error: invalid alignment value 3
test.asm:6: error: segment alignment `3' is not power of two
4:      DWORD (A5) PUBLIC (C2) USE16 size 0001
FOO                   0000:0001  0001h PAGE  PUBLIC  FOO
8:      PARA (A3) PUBLIC (C2) USE16 size 0001
FOO                   0001:0000  0001h PARA  PUBLIC  FOO
16:      PARA (A3) PUBLIC (C2) USE16 size 0001
FOO                   0001:0000  0001h PARA  PUBLIC  FOO
32:      PAGE (A4) PUBLIC (C2) USE16 size 0001
FOO                   0010:0000  0001h PAGE  PUBLIC  FOO
64:      PAGE (A4) PUBLIC (C2) USE16 size 0001
FOO                   0010:0000  0001h PAGE  PUBLIC  FOO
128:      PAGE (A4) PUBLIC (C2) USE16 size 0001
FOO                   0010:0000  0001h PAGE  PUBLIC  FOO
256:      PAGE (A4) PUBLIC (C2) USE16 size 0001
FOO                   0010:0000  0001h PAGE  PUBLIC  FOO
512:      LTL (A6) PUBLIC (C2) USE16 size 0001
FOO                   0000:0001  0001h PAGE  PUBLIC  FOO
1024:      LTL (A6) PUBLIC (C2) USE16 size 0001
FOO                   0000:0001  0001h PAGE  PUBLIC  FOO
2048:      LTL (A6) PUBLIC (C2) USE16 size 0001
FOO                   0000:0001  0001h PAGE  PUBLIC  FOO
4096:      LTL (A6) PUBLIC (C2) USE16 size 0001
FOO                   0000:0001  0001h PAGE  PUBLIC  FOO
8192: test.asm:5: error: invalid alignment value 8192
test$
Comment 3 E. C. Masloch 2025-08-28 12:02:20 PDT
I fixed WarpLink so that it supports DWORD and 4KIB alignment in the same way that NASM does. The prior revision was used in one of the above tests.

Changeset: https://hg.pushbx.org/ecm/warplink/

Build download will be at: https://pushbx.org/ecm/download/old/warplink/20250828.zip
Comment 4 E. C. Masloch 2025-08-28 12:03:20 PDT
Correction, the WarpLink changeset is at https://hg.pushbx.org/ecm/warplink/rev/6ab94e11b3cb
Comment 5 E. C. Masloch 2025-08-29 07:19:00 PDT
New WarpLink revision in https://hg.pushbx.org/ecm/warplink/rev/bfd7729482b8

The prior patch had a bug where stack segments would have some padding added wrongly. The new build will be available at https://pushbx.org/ecm/download/old/warplink/20250829.zip
Comment 6 H. Peter Anvin 2025-09-05 22:12:13 PDT
Fixed the warning on the current master branch (will be in 3.00rc4.)